﻿using AutoMapper;
using DFGK_WMS.Context;
using DFGK_WMS.IRepository;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Repository
{
    public class TStackerRepository: BaseRepository<TStacker>, ITStackerRepository
    {
        public TStackerRepository(DFGK_DB context, IMapper mapper) : base(context, mapper)
        {
        }
        /// <summary>
        /// 堆垛机信息添加
        /// </summary>
        /// <param name="stacker"></param>
        /// <returns></returns>
        public bool AddTStacker(TStacker stacker)
        {
            Context.TStackers.Add(stacker);
            return Context.SaveChanges() > 0;
        }
        /// <summary>
        /// 堆垛机信息修改
        /// </summary>
        /// <param name="stacker"></param>
        /// <returns></returns>
        public bool UpdateTStacker(TStacker stacker)
        {
            Context.TStackers.Update(stacker);
            return Context.SaveChanges() > 0;
        }
        /// <summary>
        /// 堆垛机信息查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public TStacker GetStacker(Expression<Func<TStacker, bool>> where)
        {
            return Context.TStackers.Where(where).FirstOrDefault();
        }
    }
}
